
<?php
require_once('include/header.php');

session_start();
if(!isset($_SESSION['global_purab']))
{
	header("location:login.php");
}

if($_POST['Submit']!=''){
$videoname = $_REQUEST['videoname'];
$videocode = $_REQUEST['videocode'];
$query = "INSERT INTO videos VALUES ('NULL', '$videoname', '$videocode', '1')";
mysql_query($query) or die("SQL error".mysql_error());
}

?> 

<div class="friends" id="body" style="padding:10px; width:480px;">Insert YouTube Video Name and Url.<a href="logout.php" class="help_close">Logout</a><br>
  <? if($videoname){ ?> <span class="error"><?=$videoname ?> Video Uploaded Successfully.</span><? }?>  <br>
<form action="insert_video.php" method="post" name="youtube" class="answer_note" id="youtube" style="padding:10px;">
  <label>Video Name
  <input name="videoname" type="text" class="inputtext" id="videoname" size="50">
  </label>
  <br><br>


  <label>Video Url
  <input name="videocode" type="text" class="inputtext" id="videocode" size="60">
  </label><br>
<br>

  <label>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  <input name="Submit" type="submit" class="inputsubmit" id="Submit" value="Submit">
  </label>
</form>
</div>
<div class="friend_selector" style="width:500px;">
<?
$query = "SELECT id FROM videos";
$result = mysql_query($query) or die("Error - ".mysql_error());
$rows=mysql_num_rows($result);

$ppp=8; // NUMBER OF VIDEOS PER PAGE IN ADMIN AREA
$number_of_pages  = ceil($rows / $ppp);

echo "<p align='left'><font size='2'><b>Page: </font> ";

for ($i = 1 ; $i <= $number_of_pages ; $i++){
echo "&nbsp;<b><font size='2'><a href='insert_video.php?page=$i'>$i</font></a></b>&nbsp;";
}

if($_GET['page']){
                  $page = $_GET['page'];
                 }else{
                        $page = 1;
                      }
echo "</p>";

$start = ($page - 1) * $ppp;

echo "<center>";

echo "<table width='100%'  border='0' bordercolor='#ffffff' cellpadding='1' cellspacing='1'>";
echo "<tr align='left'>";

$top=1;

$query=" SELECT * FROM videos ORDER BY id DESC LIMIT $start ,$ppp ";
$result = mysql_query($query) or die (mysql_error());
while($row=mysql_fetch_array($result)){

$id=$row['id'];
$videoname=$row['videoname'];
$videocode=$row['videocode'];
$counter=$row['counter'];

if($top="2" ){$top =1;echo "</tr><tr>";}
?>
<TD align='center' valign='middle'>
<br>
<? echo "<table><tr><td>$videocode</td></tr></table>"; ?>
<? print $videoname; ?>
<form action='delete.php' method='post'>
<input type='hidden' name='id' value='<? echo $id; ?>'>
<input name='submit' type='submit' class="inputsubmit" value='Delete'>
</form>

<hr width='80%' color='#000000'>
</TD>
<? 
$ancla++;
}
?>
</div>
<?php require_once('include/footer.php'); ?> 